<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="pageContent">
	<form method="post" id="redForm" action="${rootUrl}/info/red/${red.id}" class="pageForm required-validate" onsubmit="return beforeSubmit(this);">
		<c:if test="${red.id != 0 && red.id != '' }"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" id="redId" name="red.id" value="${red.id }">
		<div class="pageFormContent" layoutH="56">
			<p>
				<label>红包名称：</label>
				<input  name="red.title" type="text" class="required " size="30" value="${red.title}"/>
			</p>
			<p>
				<label>总金额：</label>
			    <input name="theAmount" class="required digits" type="text" size="30" value="<fmt:formatNumber value="${red.amount/100}" pattern="0"/>" onfocus="if (value =='0'){value =''}"  
            		onblur="if (value ==''){value='0'}"/>
			</p>
			<p>
			  <label>种子红包数量:</label>
			  <input  name="red.num" type="text" class="required digits"  size="30" value="${red.num}"/>
			</p>
			<p>
			  <label>每个红包多少人领取：</label>
			  <input  name="red.perNum"  type="text" class="required digits" size="30" value="${red.perNum}"/>
			</p>
			<p>
				<label>祝福语：</label>
				<input  name="red.wishing" type="text" size="30" value="${red.wishing}" />
			</p>
			<p>
				<label>开始时间：</label>
				<input type="text" name="red.startTime" class="required date" readonly="readonly" size="30" dateFmt="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${red.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /><a class="inputDateButton" href="javascript:;">选择</a>
			</p>
			<p>
				<label>结束时间：</label>
				<input type="text" id="endTime" name="red.endTime" class="required date" readonly="readonly" size="30" dateFmt="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${red.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /><a class="inputDateButton" href="javascript:;">选择</a>
			</p>
			<dl class="nowrap">
				<dt>备注：</dt>
				<dd><textarea name="red.remark" cols="153" rows="5">${red.remark}</textarea></dd>
			</dl>
   		 </div>
    	<div class="formBar">
			<ul>
				<li><div id= "redButton" ><div class="buttonContent"><button  onclick ="checkEndTime()" type="button">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
    </form>
</div>
<script>
var myDate = new Date();
var currentTime = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate()+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds();
var eTime=$("#endTime").val();
var result = (Date.parse(eTime) - Date.parse(currentTime)) / 3600 / 1000;
 $(function(){
	 if($("#redId").val() == ""){
	    $("#redButton").attr("class","buttonActive");
	 }else{
    if(result<0){
    	$("#redButton").attr("class","buttonDisabled");
    }else if(result>=0){
    	$("#redButton").attr("class","buttonActive");
    }}
}); 
function checkEndTime(){
	if($("#redId").val() == ""||result>=0){
	$("#redForm").submit();
	}
}
function beforeSubmit(obj){
	return validateCallback(obj, newDialogAjaxDone);
} 
</script>